#ifndef __LIB_AGORA_ADMIN_SERIALIZER_H__
#define __LIB_AGORA_ADMIN_SERIALIZER_H__

#include <list>
#include <map>
#include <string.h>
#include "AdminIChannel.h"
#include "AdminIUser.h"
#include "AdminIHostRight.h"
#include "AdminIChannelRight.h"

namespace AgoraAdmin
{

	class AdminSerializer
	{
	public:
		struct ChannelInfo
		{
			std::string				password;
			std::string				name;
			unsigned int			maxNameLength;
			unsigned int			maxPasswordLength;
			std::string				motd;
			unsigned int			maxMotdLength;
			std::string				description;
			unsigned int			maxDescriptionLength;
			bool					visible;
			unsigned int			maxUser;
			unsigned int			maxTalker;
			unsigned int			id;
			unsigned int			idParent;
		};

		struct UserInfo
		{
			unsigned int			id;
			std::string				login;
			unsigned int			idCurrentChannel;
			bool					connected;
		};
		
		struct HostRightInfo
		{
			bool			canChangeLogin;
			bool			canChangePassword;
			bool			canChangeChannel;
			bool			canCreateChannel;
			bool			canDeleteChannel;
			bool			canMoveChannel;
			bool			canKickUser;
			bool			canBanUser;
			bool			canEditUser;
		};

		struct ChannelRightInfo
		{
			bool			canCreate;
			bool			canDelete;
			bool			canEdit;
			bool			canEditUser;
			bool			canTalk;
			bool			canWrite;
			bool			canKick;
			bool			canBan;
		};


		static std::list<ChannelInfo*>*		UnserializeChannelList(char *data, unsigned int& size);
		static ChannelInfo*					UnserializeChannelInfo(char *data, unsigned int& size);
		static void*						SerializeChannelList(const std::map<unsigned int, IChannel *>& chanMap, unsigned int& size);
		static std::list<UserInfo*>*		UnserializeUserList(char* data, unsigned int& size);
		static UserInfo*					UnserializeUserInfo(char* data, unsigned int& size);
		static void*						SerializeUserInfo(UserInfo& userInfo, unsigned int& size);
		static void*						SerializeUserList(const std::map<unsigned int, IUser*>& userMap, unsigned int& size);
		static void*						SerializeHostRight(const IHostRight *rights, unsigned int& size);
		static HostRightInfo*				UnserializeHostRight(char *data, unsigned int& size);
		static void*						SerializeHostRightInfo(const HostRightInfo* info, unsigned int& size);
		static void*						SerializeChannelRight(const IChannelRight *rights, unsigned int& size);
		static ChannelRightInfo*			UnserializeChannelRight(char *data, unsigned int& size);
		static void*						SerializeHostChannelInfo(const ChannelRightInfo* info, unsigned int& size);

	private:
		static void							SerializeChannel(const IChannel *chan, void *data, unsigned int& size);
		static void							SerializeUser(const IUser* user, void* data, unsigned int& size);

	};

}

#endif
